/**
 * jims
 */
package com.jims.master.modules.patient.myAttention.service;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.common.utils.StringUtils;
import com.jims.master.modules.base.user.entity.MasterDoctorinfo;
import com.jims.master.modules.patient.myAttention.dao.PatFollowDao;
import com.jims.master.modules.patient.myAttention.entity.PatFollow;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Service
 * @author jicunteng
 * @version 2017-05-23
 */
@Service
public class PatFollowService extends CrudService<PatFollowDao, PatFollow> {

	/**
	 * 查询用户关注的医生
	 * @param
	 * @return
	 * @author jicunten
	 */
	public  Page<PatFollow> findUserPatFollow(Page<PatFollow> page,Map map){
		page.setPageNo(Integer.parseInt((String) map.get("pageNo")));
		if(StringUtils.isNotBlank((String) map.get("pageSize"))){
			page.setPageSize(Integer.parseInt((String) map.get("pageSize")));
		}else{
			page.setPageSize(10);
		}
		PatFollow patFollow = new PatFollow();
		patFollow.setPersonId((String)map.get("personId"));
		patFollow.setPage(page);
		page.setList(this.dao.findUserPatFollow(patFollow));
        return page;
	}

	/**
	 * 删除用户关注的医生
	 * @param personId
	 * @param doctorId
	 * @return
	 * @author jicunteng
	 */
	@Transactional(readOnly = false)
	public int deleteUserPatFollow(String personId,String doctorId){
		return dao.deleteUserPatFollow(personId, doctorId);
	}

	/**
	 * 查询是否已经关注医生
	 * @param patFollow
	 * @return
	 * @author chentao
	 */
	public PatFollow getPatFollowByUser(PatFollow patFollow){
		return dao.getPatFollowByUser(patFollow);
	}
}